mruby 4.0.0
mruby is the lightweight implementation of the Ruby language
Loading...
Searching...
No Matches
dump.h File Reference

More...

#include <mruby.h>
#include <mruby/irep.h>
#include "common.h"
Include dependency graph for dump.h:

Go to the source code of this file.

Classes

struct  rite_binary_header
 
struct  rite_section_header
 
struct  rite_section_irep_header
 
struct  rite_section_debug_header
 
struct  rite_section_lv_header
 
struct  rite_binary_footer
 

Macros

#define MRB_DUMP_DEBUG_INFO   1
 Dumping compiled mruby script.
 
#define MRB_DUMP_STATIC   2
 
#define MRB_DUMP_NO_LVAR   4
 
#define MRB_DUMP_OK   0
 
#define MRB_DUMP_GENERAL_FAILURE   (-1)
 
#define MRB_DUMP_WRITE_FAULT   (-2)
 
#define MRB_DUMP_READ_FAULT   (-3)
 
#define MRB_DUMP_INVALID_FILE_HEADER   (-4)
 
#define MRB_DUMP_INVALID_IREP   (-5)
 
#define MRB_DUMP_INVALID_ARGUMENT   (-6)
 
#define MRB_DUMP_NULL_SYM_LEN   0xFFFF
 
#define RITE_BINARY_IDENT   "RITE"
 
#define RITE_BINARY_MAJOR_VER   "04"
 
#define RITE_BINARY_MINOR_VER   "00"
 
#define RITE_BINARY_FORMAT_VER   RITE_BINARY_MAJOR_VER RITE_BINARY_MINOR_VER
 
#define RITE_COMPILER_NAME   "MATZ"
 
#define RITE_COMPILER_VERSION   "0000"
 
#define RITE_VM_VER   "0400"
 
#define RITE_BINARY_EOF   "END\0"
 
#define RITE_SECTION_IREP_IDENT   "IREP"
 
#define RITE_SECTION_DEBUG_IDENT   "DBG\0"
 
#define RITE_SECTION_LV_IDENT   "LVAR"
 
#define MRB_DUMP_DEFAULT_STR_LEN   128
 
#define MRB_DUMP_ALIGNMENT   sizeof(uint32_t)
 
#define RITE_SECTION_HEADER
 
#define RITE_LV_NULL_MARK   UINT16_MAX
 

Functions

mrb_value mrb_load_irep_file (mrb_state *, FILE *)
 
mrb_value mrb_load_irep_file_cxt (mrb_state *, FILE *, mrb_ccontext *)
 
mrb_irepmrb_read_irep_file (mrb_state *, FILE *)
 
int mrb_dump_irep_binary (mrb_state *, const mrb_irep *, uint8_t, FILE *)
 Dumps an IREP (Intermediate Representation) into a binary format and writes it to a file.
 
mrb_irepmrb_read_irep (mrb_state *, const uint8_t *)
 
mrb_irepmrb_read_irep_buf (mrb_state *, const void *, size_t)
 
static size_t uint8_to_bin (uint8_t s, uint8_t *bin)
 
static size_t uint16_to_bin (uint16_t s, uint8_t *bin)
 
static size_t uint32_to_bin (uint32_t l, uint8_t *bin)
 
static uint32_t bin_to_uint32 (const uint8_t *bin)
 
static uint16_t bin_to_uint16 (const uint8_t *bin)
 
static uint8_t bin_to_uint8 (const uint8_t *bin)
 

Detailed Description

  • mruby binary dumper (mrbc binary format)

See Copyright Notice in mruby.h

Macro Definition Documentation

◆ RITE_SECTION_HEADER

#define RITE_SECTION_HEADER
Value:
uint8_t section_ident[4]; \
uint8_t section_size[4]

Function Documentation

◆ mrb_dump_irep_binary()

int mrb_dump_irep_binary ( mrb_state * mrb,
const mrb_irep * irep,
uint8_t flags,
FILE * fp )

Dumps an IREP (Intermediate Representation) into a binary format and writes it to a file.

This function first calls mrb_dump_irep to get the binary representation of the IREP, then writes the binary data to the specified file pointer.

Parameters
mrbThe mruby state.
irepThe IREP to dump.
flagsFlags to control the dump process.
fpThe file pointer to write the binary data to.
Returns
MRB_DUMP_OK on success, or an error code (e.g., MRB_DUMP_INVALID_ARGUMENT, MRB_DUMP_WRITE_FAULT) on failure.